Skip to content

[codex] Add local-first GitHub sync catch-up#179

Merged
stylessh merged 3 commits intomainfrom
stylessh/oauth-app-balance
Apr 25, 2026
Merged

[codex] Add local-first GitHub sync catch-up#179
stylessh merged 3 commits intomainfrom
stylessh/oauth-app-balance

Conversation

@stylessh
Copy link
Copy Markdown
Owner

@stylessh stylessh commented Apr 25, 2026

Summary

Make the dashboard more local-first by serving cached GitHub data immediately, catching up after missed webhook signals, and actively refreshing workflow approval state.

Changes

  • add local-first GitHub cache metadata and background revalidation for hot reads, including pull status, repo overview, inbox notifications, and my lists
  • make signal catch-up compare against cached GitHub fetch timestamps and retry on reconnect, focus, visibility, and online resume
  • subscribe inbox and pull status to the relevant webhook signals, including repo protection and pending workflow runs
  • fix the "Approve workflows to run" CTA so it refetches checks immediately instead of getting stuck waiting for a webhook

Test Plan

  • pnpm install
  • pnpm --filter dashboard check-types
  • pnpm --filter dashboard exec vitest run src/lib/use-github-signal-stream.test.ts

Screenshots

Before After
Previous UI After UI

Summary by CodeRabbit

Release Notes

  • New Features

    • Local-first caching enables faster data loading with background refreshes
    • Real-time webhook integration provides instant updates to pull requests, issues, and notifications
    • Pull requests automatically removed from open views when closed or merged
  • Improvements

    • Pull status and repository pages refresh immediately on relevant changes
    • Notification updates synchronized in real-time across the dashboard
    • Enhanced cache synchronization for better data consistency

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 54dab6b9-79ae-456f-8936-c49dac01fc16

📥 Commits

Reviewing files that changed from the base of the PR and between 505d2a6 and 3b01151.

📒 Files selected for processing (15)
  • apps/dashboard/src/components/details/detail-activity.tsx
  • apps/dashboard/src/components/inbox/inbox-page.tsx
  • apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx
  • apps/dashboard/src/components/pulls/detail/pull-detail-page.tsx
  • apps/dashboard/src/components/repo/repo-activity-cards.tsx
  • apps/dashboard/src/components/repo/repo-overview-page.tsx
  • apps/dashboard/src/lib/github-cache-invalidation.test.ts
  • apps/dashboard/src/lib/github-cache.ts
  • apps/dashboard/src/lib/github-query-updates.ts
  • apps/dashboard/src/lib/github-revalidation.ts
  • apps/dashboard/src/lib/github.functions.ts
  • apps/dashboard/src/lib/github.types.ts
  • apps/dashboard/src/lib/use-github-signal-stream.test.ts
  • apps/dashboard/src/lib/use-github-signal-stream.ts
  • apps/dashboard/src/routes/_protected/index.tsx

📝 Walkthrough

Walkthrough

This PR implements a local-first caching strategy with webhook-driven signal streaming for GitHub data. It introduces getGitHubResourceLocalFirst for immediate cache returns with background revalidation, expands notification signals across webhook events, integrates signal streams into dashboard components for cache invalidation, adds removePullFromOpenViews to sync cache state, and updates data layer types to carry local-first metadata.

Changes

Cohort / File(s) Summary
Local-first cache infrastructure
apps/dashboard/src/lib/github-cache.ts
Adds getGitHubResourceLocalFirst API returning cached data immediately with background revalidation, introduces resolveGitHubCacheEntry helper to unify legacy/split payload resolution, and adds support for completion callbacks and executionContext waitUntil.
Signal key expansion
apps/dashboard/src/lib/github-revalidation.ts, apps/dashboard/src/lib/github-cache-invalidation.test.ts
Introduces global notifications signal key and extends getGitHubWebhookRevalidationSignalKeys to include notifications across installation, pull/issue, push, workflow, and repository protection events.
Component signal stream integration
apps/dashboard/src/components/inbox/inbox-page.tsx, apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx, apps/dashboard/src/components/pulls/detail/pull-detail-page.tsx, apps/dashboard/src/components/repo/repo-activity-cards.tsx, apps/dashboard/src/components/repo/repo-overview-page.tsx, apps/dashboard/src/routes/_protected/index.tsx
Multiple components now set up webhook refresh targets with useGitHubSignalStream for dynamic query revalidation; inbox page memoizes filter input and normalizes optimistic updates; pull detail page adds repo protection signals; repo components compute entity-level signal keys from loaded data; dashboard index derives per-query signal keys dynamically and adjusts recent pull sorting.
Pull removal from cache
apps/dashboard/src/components/details/detail-activity.tsx
DetailCommentBox now calls removePullFromOpenViews after successfully closing a PR to sync cached open views.
Cache synchronization utility
apps/dashboard/src/lib/github-query-updates.ts
New module exporting removePullFromOpenViews to filter closed PRs from React Query cache, update user pull lists, and decrement repo open pull count.
Type system extensions
apps/dashboard/src/lib/github.types.ts
Adds GitHubLocalFirstMeta type with cacheStatus, fetchedAt, and isRevalidating fields; extends result types (MyPullsResult, MyIssuesResult, PullStatus, PullPageData, etc.) with optional __meta field.
Signal stream utilities
apps/dashboard/src/lib/use-github-signal-stream.ts, apps/dashboard/src/lib/use-github-signal-stream.test.ts
Adds getGitHubSignalComparisonTimestamp and getGitHubDataFetchedAt helpers to prefer local-first metadata over query timestamps; introduces throttled resume logic on visibility/focus/online changes with 5s minimum interval between sync attempts; includes test suite validating timestamp resolution logic.
Data layer local-first adoption
apps/dashboard/src/lib/github.functions.ts
Upgrades cache-backed APIs (getPullStatus, getPullPageData, getIssuePageData, getMyPulls, getMyIssues, getRepoOverview, getNotifications) to use getGitHubResourceLocalFirst, extract background execution context from request context, broadcast refreshed signal keys on completion, and wrap results with local-first metadata; strengthens repo validation and adjusts bypass decision logic.

Sequence Diagram

sequenceDiagram
    participant Component
    participant LocalCache as Cache Layer
    participant SignalStream as Signal Stream
    participant Server
    participant WebSocket as WebSocket/Events

    Component->>LocalCache: Request data (getGitHubResourceLocalFirst)
    LocalCache->>LocalCache: Check cache status<br/>(fresh/stale/miss)
    LocalCache-->>Component: Return cached data immediately<br/>+ metadata
    LocalCache->>Server: Background refresh (if stale/miss)
    
    Server-->>LocalCache: New data + refresh timestamp
    LocalCache->>LocalCache: Update cache entry<br/>+ fetchedAt timestamp
    LocalCache->>SignalStream: Broadcast refreshed signal keys
    
    WebSocket->>Server: GitHub webhook event
    Server->>SignalStream: Emit revalidation signal
    SignalStream->>SignalStream: Compare signal timestamp<br/>vs cached fetchedAt
    SignalStream->>Component: Trigger query revalidation
    Component->>LocalCache: Request data (cache miss/refresh)
    LocalCache-->>Component: Return updated data
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stylessh/oauth-app-balance

Comment @coderabbitai help to get the list of available commands and usage tips.

@stylessh stylessh marked this pull request as ready for review April 25, 2026 20:04
@stylessh stylessh merged commit 4bfe010 into main Apr 25, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant